package com.yonyou.crm.sys.queryplan.ctrl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONObject;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.yonyou.crm.common.enumeration.entity.ClientTypeEnum;
import com.yonyou.crm.common.exception.CrmMessageException;
import com.yonyou.crm.common.rest.util.ResponseUtil;
import com.yonyou.crm.sys.queryplan.entity.QueryPlanVO;
import com.yonyou.crm.sys.queryplan.rmitf.IQueryPlanRmSerivice;

@RestController
@RequestMapping(value = "/sys/queryplans")
public class QueryPlanCtrl {
	
	@Autowired
	private IQueryPlanRmSerivice rmService;
	
	@RequestMapping(value = "{menuId}/{objId}", method = RequestMethod.GET)
	public Object getQueryPlanList(@PathVariable("menuId") Long menuId, @PathVariable("objId") Long objId, HttpServletRequest request, HttpServletResponse response) throws CrmMessageException {
	
		if (menuId == null || objId == null) {
			throw new CrmMessageException("");
		}
		
		Map<String, Object> param = new HashMap<String, Object>();
		param.put("objId", objId);
		param.put("clientType", ClientTypeEnum.PC.getValue());
		param.put("menuId", menuId);
		List<QueryPlanVO> queryPlanList = rmService.getQueryPlanList(param);
		JSONObject result = new JSONObject();
		result.put("data", queryPlanList);
		return ResponseUtil.getObject(result);
	}
}
